IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InjectNewAnimalBoards]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[InjectNewAnimalBoards]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO



/***************************************************************************
* Name:				
* Purpose:		Using table Stg_AnimalBoards, update Org and Person IDs from Asset
*
* PARAMETERS
* Name				Description					
* -------------		-----------------------------------------------------------
* n/a
*
* ERRORS USED		Description			
* -------------		-----------------------------------------------------
* n/a
*
* RETURN VALUE
* Value    			Description					
* --------------	------------------------------------------------------
***************************************************************************/
CREATE PROCEDURE dbo.InjectNewAnimalBoards
AS
BEGIN


	SET NOCOUNT ON


	Insert INTO IRBBoard (
		BoardName,
		RexMailGroupId,
		IRBBoardTypeId, 
		FwkDomainOrganizationId,
		SequenceId )
	SELECT  sDescription,
			nMailGroupId,
			IRBBoardTypeId,
			InstitutionId,
			SequenceId
			FROM Stg_AnimalBoards WHERE nMailGroupID not in 
			(select RexMailGroupId from IRBBoard)

	SET NOCOUNT OFF

	END

GO
